	//uniform sampler2DShadow depthTexture;
	uniform sampler2D depthTexture;
	varying vec4 q;
	varying float zValue;
	void main()
	{
		float farLight = 100.0;
		float zValueLight = q.z/farLight;
		//zValueLight = 0.5 * (zValueLight + 1.0);
		vec3 coord = 0.5 * (q.xyz / q.w + 1.0);
		
		float shadow = 1.0;
		#if 0	
			float dt = 1.0/512;
			float shadow0 = coord.z > texture2D(depthTexture, vec2(coord.s, coord.t) ).r?0.0:1.0;
			float shadow1 = coord.z > texture2D(depthTexture, vec2(coord.s, coord.t+dt) ).r?0.0:1.0;
			float shadow2 = coord.z > texture2D(depthTexture, vec2(coord.s+dt, coord.t+dt) ).r?0.0:1.0;
			float shadow3 = coord.z > texture2D(depthTexture, vec2(coord.s+dt, coord.t) ).r?0.0:1.0;
			shadow = 0.25 * (shadow0 + shadow1 + shadow2 + shadow3);
			
			//float shadow0 = shadow2D(depthTexture, coord).r;
			//float shadow1 = shadow2D(depthTexture, coord + vec3(0.0, dt, 0.0)).r;
			//float shadow2 = shadow2D(depthTexture, coord + vec3(dt, dt, 0.0)).r;
			//float shadow3 = shadow2D(depthTexture, coord + vec3(dt, 0.0, 0.0)).r;
			//float shadow = 0.25 * (shadow0 + shadow1 + shadow2 + shadow3);
		#else		
			float depth = texture2D(depthTexture, coord.st).r;
			//if( coord.z > depth)
			//	shadow = 0.0;
			if( zValueLight > depth)
				shadow = 0.0;
				
		#endif
		
		gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0) * shadow;
		
	}